﻿ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;
using ZF.BLL.Page;

namespace ZF.WS.ads
{
    public partial class companylist :PageBase
    {

        [PageArgument(Key = "tid",DefaultValue=0)]
        public int tid { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            var typeList = DictionaryConfig.APopularizeCompanyType;
            this.lvTitle.DataSource = typeList;
            this.lvTitle.DataBind();
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                List<object> list = null;
                var sel = dc.AD_Popularize.Where(p => true);
                if (tid != 0)
                   sel= sel.Where(p => p.TypeId == this.tid);

                list = sel.OrderByDescending(p => p.OrderId).ToList().Select(p =>
                        (object)new
                        {
                            Popularize = p,
                            Url = string.IsNullOrEmpty(p.Url) ? "/ads/Company.aspx?id=" + p.PopularizeId.ToString() : p.Url,
                        }).ToList();
              
                this.lvList.DataSource = list;
                this.lvList.DataBind();


            }
        }
    }
}